﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/masAdmin.master" AutoEventWireup="true"
    CodeFile="ProductList.aspx.cs" Inherits="admin_ProductList" %>

<%@ Register Assembly="CommonTagTime" Namespace="CommonTagTime.PagerControl" TagPrefix="cc1" %>
<asp:Content ID="Content3" ContentPlaceHolderID="pagename" runat="Server">
    Product List
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="Server">
    <div class="content-box-header">
        <h3>
            Search Box</h3>
    </div>
    <div class="content-box-content">
        <table id="tab1" class="table100" cellpadding="2" cellspacing="2">
            <tr>
                <td align="right" style="width: 120px">
                    Category
                </td>
                <td style="width: 165px">
                    <asp:DropDownList ID="F_drlCategory" Width="160px" runat="server">
                    </asp:DropDownList>
                </td>
               <td style="width: 60px" align="right">
                    SKU:
                </td>
                <td style="width: 200px">
                    <asp:TextBox ID="F_txtSKU" runat="server" Width="120px" MaxLength="6"></asp:TextBox>
                </td>
                <td></td>
            </tr>
            <tr>
               
                <td  align="right">
                    Product Name:
                </td>
                <td colspan="3">
                    <asp:TextBox ID="F_txtName" runat="server" Width="365px" MaxLength="100"></asp:TextBox>
                </td>
                <td></td>
            </tr>
            <tr>
                <td align="right">
                    Is Active?
                </td>
                <td align="left">
                    <asp:DropDownList ID="F_ddlIsAvtive" runat="server">
                    </asp:DropDownList>
                </td>
                <td align="right">
                    Is New?
                </td>
                <td>
                    <asp:DropDownList ID="F_ddlIsNew" runat="server">
                    </asp:DropDownList>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>
                </td>
                <td colspan="3">
                    <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="button" OnClick="btnSearch_Click" />
                    <asp:Button ID="btnReset" runat="server" OnClientClick="return ResetForm();" Text="Reset"
                        CssClass="button" />
                </td>
                <td></td>
            </tr>
        </table>
    </div>
    <div id="divGrid" runat="server" class="box">
        <div class="pagination right">
            <cc1:Pager ID="Pager2" runat="server" OnPageIndexChanging="Pager2_PageIndexChanging"
                OnPageSizeChanging="Pager2_PageSizeChanging" />
        </div>
        <div>
            <asp:Button ID="btnDelete" Text="Delete" runat="server" CssClass="button" OnClientClick="return CheckDelete();"
                OnClick="btnDelete_Click" />
            <asp:Button ID="btnAddNew" Text="Add New" runat="server" CssClass="button" OnClick="btnAddNew_Click" />
        </div>
        <asp:Repeater ID="rptData" runat="server" OnItemCommand="rptData_ItemCommand" OnItemDataBound="rptData_ItemDataBound">
            <HeaderTemplate>
                <table class="table100" border="0">
                    <thead>
                        <th class="gridCheckBoxColumHeader">
                            <input id="chkCheckAll" type="checkbox" onclick="CheckAll(this.checked)" />
                        </th>
                        <th class="gridNoColumHeader">
                            #
                        </th>
                        <th style="width: 100px;">
                            <asp:LinkButton ID="lbtnSKU" runat="server" Text="Mã SP" CommandName="SortOrder" CommandArgument="SKU">
                            </asp:LinkButton>
                        </th>
                        <th class="align-left">
                             <asp:LinkButton ID="lbtnName" runat="server" Text="Tên" CommandName="SortOrder" CommandArgument="Name">
                            </asp:LinkButton>
                        </th>
                        <th style="width: 120px;">
                             <asp:LinkButton ID="lbtnPrice" runat="server" Text="Giá" CommandName="SortOrder" CommandArgument="NowPrice"></asp:LinkButton>
                        </th>
                        <th class="gridActiveColumHeader">Hiển thị</td>
                            <th class="gridActiveColumHeader">
                                HOT
                            </th>
                            <th class="griActionColumHeader">
                                Action
                            </th>
                            <th style="width: 80px;">
                                Liên quan
                            </th>
                              <th style="width:80px;">
                               Cùng loại
                            </th>
                    </thead>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td align="center">
                        <input type="checkbox" name="chk_<%#Eval("ProductId") %>" id="chk_<%#Eval("ProductId") %>"
                            onclick="CheckItem('<%#Eval("ProductId") %>',this.checked);" />
                    </td>
                    <td align="center">
                        <%#Container.ItemIndex + 1%>
                    </td>
                    <td align="center">
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit&<%=paraURL %>" class="detail"><%#Eval("SKU") %></a>
                    </td>
                    <td>
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit&<%=paraURL %>" class="detail"><%#Eval("Name") %></a>
                    </td>
                    <td align="right" style="padding-right: 30px;">
                        <%#Convert.ToDouble(Eval("NowPrice")) != 0 ? string.Format(@"{0:N0}", Eval("NowPrice")) : "" %>
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbActive" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="Active" />
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbIsNew" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="New" />
                    </td>
                    <td align="center">
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit&<%=paraURL %>">
                            <img src="/App_Themes/Admin/images/icons/pencil.png" alt="Edit" title="Edit" />
                        </a>
                        <asp:ImageButton ID="imbDelete" runat="server" ImageUrl="~/App_Themes/Admin/images/cross_circle.png"
                            CommandName="Delete" />
                    </td>
                    <td style="text-align: center">
                        <asp:Literal ID="ltrRelatedItem" runat="server"></asp:Literal>
                    </td>
                     <td style="text-align: center">
                        <asp:Literal ID="ltrMSDS" runat="server"></asp:Literal>
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="alt-row">
                    <td align="center">
                        <input type="checkbox" name="chk_<%#Eval("ProductId") %>" id="chk_<%#Eval("ProductId") %>"
                            onclick="CheckItem('<%#Eval("ProductId") %>',this.checked);" />
                    </td>
                    <td align="center">
                        <%#Container.ItemIndex + 1%>
                    </td>
                    <td align="center">
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit&<%=paraURL %>" class="detail"><%#Eval("SKU") %></a>
                    </td>
                    <td>
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit&<%=paraURL %>" class="detail"><%#Eval("Name") %></a>
                    </td>
                    <td align="right" style="padding-right: 30px;">
                        <%#Convert.ToDouble(Eval("NowPrice")) != 0 ? string.Format(@"{0:N0}", Eval("NowPrice")) : "" %>
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbActive" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="Active" />
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbIsNew" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="New" />
                    </td>
                    <td align="center">
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit&<%=paraURL %>">
                            <img src="/App_Themes/Admin/images/icons/pencil.png" alt="Edit" title="Edit" />
                        </a>
                        <asp:ImageButton ID="imbDelete" runat="server" ImageUrl="~/App_Themes/Admin/images/cross_circle.png"
                            CommandName="Delete" />
                    </td>
                    <td style="text-align: center">
                        <asp:Literal ID="ltrRelatedItem" runat="server"></asp:Literal>
                    </td>
                      <td style="text-align: center">
                        <asp:Literal ID="ltrMSDS" runat="server"></asp:Literal>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <div class="pagination">
            <cc1:Pager ID="Pager1" runat="server" OnPageIndexChanging="Pager2_PageIndexChanging"
                OnPageSizeChanging="Pager2_PageSizeChanging" />
        </div>
        <input type="hidden" value="" runat="server" id="hidProductID" />
        <input type="hidden" value="" runat="server" id="hidProductIDSelect" />
    </div>
    <div id="divEmplty" runat="server" visible="false">
    </div>
    <script type="text/javascript">
        function CheckAll(status) {
            var id = document.getElementById('<%=hidProductID.ClientID %>').value;
            var arr = new Array();
            arr = id.split(';');
            if (arr.length > 0) {
                for (var i = 0; i < arr.length; i++) {
                    if (document.getElementById('chk_' + arr[i].toString())) {
                        document.getElementById('chk_' + arr[i].toString()).checked = status;

                    }
                }

            }
            if (status) {
                document.getElementById('<%=hidProductIDSelect.ClientID %>').value = id;
            }
            else document.getElementById('<%=hidProductIDSelect.ClientID %>').value = '';

        }
        function CheckItem(id, status) {

            var idSelect = document.getElementById('<%=hidProductIDSelect.ClientID %>').value;
            if (status) {
                idSelect += id + ';';
            }
            else idSelect = idSelect.replace(id + ';', '');
            if (idSelect.length == document.getElementById('<%=hidProductID.ClientID %>').value.length) {
                document.getElementById('chkCheckAll').checked = true;
            }
            else
                document.getElementById('chkCheckAll').checked = false;
            document.getElementById('<%=hidProductIDSelect.ClientID %>').value = idSelect;

        }
        function ConfirmDelete() {
            var yes = confirm('<%=Resources.Resource.MSG_CONFIRM_DELETE %>');
            return yes;
        }
        function CheckDelete() {

            var id = document.getElementById('<%=hidProductIDSelect.ClientID %>').value;
            if (id == '') {
                alert('<%=Resources.Resource.MSG_REQUIRE_SELECT_ITEM %>');
                return false;
            }
            else return ConfirmDelete();
        }
        function ResetForm() {
            document.getElementById('<%=F_txtSKU.ClientID %>').value = '';
            document.getElementById('<%=F_txtName.ClientID %>').value = '';
            document.getElementById('<%=F_ddlIsNew.ClientID %>').value = '';
            document.getElementById('<%=F_ddlIsAvtive.ClientID %>').value = '';
            document.getElementById('<%=F_drlCategory.ClientID %>').value = '';
            
            return false;
        }
    </script>
</asp:Content>
